const app = getApp()
Page({
  data: {
    isLogin: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  navTo(e) {
    let url = e.currentTarget.dataset.path;
    if (app.globalData.userInfo) {
      wx.navigateTo({
        url: url
      })
    }else{
      wx.showModal({
        title: '提示',
        content: '您尚未登录,请先完成登录！',
        showCancel: false,
        success: function () {

        }
      })
    }
  },
  getUserInfoAction(res) {
    let that = this;
    if (res.detail.userInfo) {
      //app.globalData.userInfo = res.detail.userInfo;
      wx.showLoading({
        title: '登录中',
      });
      app.appLogin(1);
    }
  },
  loginFun:function(){
    let that = this;
    app.appLogin(function (userInfo) {
      
    })
    
  },
  phoneCall: function (e) {
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.dataset.replyPhone,
      success: function () {
        //console.log("成功拨打电话")
      },
      error: function () {
        // console.log("2222")
      }
    })
  },
  isLogin(){
    let that = this;
    console.log(app.globalData.userInfo)
    if (app.globalData.userInfo){
      that.setData({
        isLogin: true
      })
    }else{
      that.setData({
        isLogin: false
      })
    }
  },
  onLoad: function (options) {
    this.isLogin();
    console.log(this.data.isLogin)
  },
  onShow: function () {
   
    
  }
})